package com.ksyun.seckill.controller.online;


import com.ksyun.seckill.rest.RestResult;
import com.ksyun.seckill.service.CampaignService;
import com.ksyun.seckill.vo.CampaignBasisInfoVO;
import com.ksyun.seckill.vo.SimpleCampaignVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Collections;
import java.util.List;


/**
 * 用户端controller
 */
@RestController
@RequestMapping(value = "/online/campaign", produces = {MediaType.APPLICATION_JSON_VALUE})
@Slf4j
public class OnlineCampaignController {

    @Autowired
    private CampaignService campaignService;

    /**
     * 用户端获取活动列表
     * @return
     */
    @RequestMapping(value = "/list", method = {RequestMethod.GET})
    public RestResult list() {
        /**
         * 这里需要注意，statusname分已开始，未开始，已结束且只能查询到以上线的活动
         */
        List<CampaignBasisInfoVO>  retList =campaignService.selectSeckCampaignList();
        return RestResult.success().data(retList);
    }


    /**
     * 查询活动详情
     * @param campaignId
     * @return
     */
    @RequestMapping(value = "/getSimpleCampaignInfo",method = RequestMethod.GET)
    public RestResult getSimpleCampaignInfo(@RequestParam("campaignId") String campaignId){
        SimpleCampaignVO ret_info=campaignService.getSimpleCampaignInfo(campaignId);
        return RestResult.success().data(ret_info);
    }

}
